package me.stephenj.experiment2.mapper;

import me.stephenj.experiment2.model.PhoneNr;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * @Title PhoneNrMapper.java
 * @Description PhoneNrMapper类
 * @author 张润天
 * @Time 2020/4/21 12:29
 * @version v0.01
 */

@Component
public interface PhoneNrMapper {

    /**
     * @Title Method
     * @Description 找到最大编号
     */
    @Select("SELECT MAX(`ID`) FROM PhoneNr")
    int max();

    /**
     * @Title Method
     * @Description 使用号码编号查找信息
     */
    @Select("SELECT * FROM PhoneNr WHERE ID=#{ID}")
    PhoneNr getPhoneNr(int ID);

    /**
     * @Title Method
     * @Description 添加电话号码
     */
    @Insert("INSERT INTO PhoneNr (ID, Name, Number) VALUE (#{ID}, #{Name}, #{Number})")
    int insert(PhoneNr phoneNr);

    /**
     * @Title Method
     * @Description 修改电话号码信息
     */
    @Update("UPDATE `PhoneNr` SET `Name`=#{Name}, `Number`=#{Number} WHERE ID=#{ID}")
    int update(PhoneNr phoneNr);

    /**
     * @Title Method
     * @Description 删除电话号码
     */
    @Delete("DELETE FROM PhoneNr WHERE ID=#{ID}")
    int delete(int ID);
}
